<template>
  <div>
    <van-nav-bar :title="title">
      <img
        slot="left"
        src="~assets/image/arrow_left.png"
        alt=""
        width="20"
        height="20"
        @click="leftClick"
      />
    </van-nav-bar>
    <div
      class="news"
      v-for="(item, index) in titleList"
      :key="index"
      @click="getSrc(item.title, item.content)"
    >
      <div class="news_count">
        <p class="news_title">{{ item.title }}</p>
        <div class="count-bon">
          <p>{{ item.createTime }}</p>
          <p>阅读: {{ item.previewNumber }}</p>
        </div>
      </div>
      <img :src="item.lowSource" alt="" width="100" height="70" />
    </div>
  </div>
</template>
<script>
import { queryNewsInfoApi } from "network/ApiServe";
export default {
  data() {
    return {
      title: "合伙人商学院",
      page: 0,
      titleList: [],
    };
  },
  created() {
    this.brandId = localStorage.getItem("brandId");
  },
  mounted() {
    this.getNewsInfo();
  },
  methods: {
    leftClick() {
      this.$router.back(-1);
    },
    getNewsInfo() {
      //brandId
      queryNewsInfoApi(this.brandId, this.title, this.page)
        .then((res) => {
          if (res.resp_code === "000000") {
            if (res.result.content != null) {
              this.titleList = res.result.content;
            }
          }
          console.log("titleList:", this.titleList);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    getSrc(titles, urls) {
      // console.log("titles", titles);
      // console.log("urls", urls);
      this.$router.push({
        name: "OpenWeb",
        params: {
          title: titles,
          url: urls,
        },
      });
    },
  },
};
</script>
<style scoped>
.news {
  display: flex;
  flex-direction: row;
  padding: 8px 15px;
}
.news_count {
  flex: 1;
  padding-right: 10px;
}
.count-bon {
  margin-top: 25px;
  display: flex;
  justify-content: space-between;
  flex-direction: row;
  align-items: flex-start;
  color: #999;
  font-size: 12px;
}
.news_title {
  font-weight: bold;
  font-size: 13px;
  color: #444;
}
</style>